package com.mall.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 通用状态枚举
 */
@Getter
@AllArgsConstructor
public enum CommonStatusEnum {
    DISABLED(0, "禁用"),
    ENABLED(1, "启用");

    private final int value;
    private final String desc;

    public static CommonStatusEnum of(Integer value) {
        if (value == null) return null;
        for (CommonStatusEnum status : values()) {
            if (status.value == value) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的状态值: " + value);
    }

    public static boolean isValid(Integer status) {

        return status != null && of(status) != null;
    }
}
